﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Newtonsoft.Json;

namespace RN.ERP.Web.Person
{
    public partial class PersonEmpRepeatList : BasePage
    {
        protected string idCard
        {
            get
            {
                return Context.Request["idcard"];
            }
        }
        protected string areaCode
        {
            get
            {
                return System.Configuration.ConfigurationManager.AppSettings["sysArea"];
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void RadAjaxManager1_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
        {
            if (e.Argument == "Rebind")
            {
                ListPersonRepeat.MasterTableView.SortExpressions.Clear();
                ListPersonRepeat.MasterTableView.GroupByExpressions.Clear();
                ListPersonRepeat.Rebind();
            }
        }

        protected void ListPersonRepeat_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            BindData();
        }

        protected void BindData()
        {
            using (PersonService.PersonServiceClient client = new PersonService.PersonServiceClient())
            {
                var rst = client.GetEmpManagerRepeat(idCard, areaCode);
                var list = JsonConvert.DeserializeObject<List<ModelService.tb_Emp_Manager>>(rst);
                ListPersonRepeat.DataSource = list;
            }
        }

        protected string TranCorpTypeByClassid(object classid)
        {
            if (classid == null)
            {
                return string.Empty;
            }
            else
            {
                string classidStr = classid.ToString();
                string rst = string.Empty;
                switch (classidStr)
                {
                    case "2501":
                    case "25010":
                        rst = "施工企业";
                        break;
                    case "2506":
                    case "25060":
                        rst = "装饰装修企业";
                        break;
                    case "2301":
                    case "23010":
                        rst = "门窗企业";
                        break;
                    case "30":
                    case "300":
                        rst = "商砼企业";
                        break;
                    default:
                        rst = "施工企业";
                        break;
                }
                return rst;
            }
        }
    }
}